<?php

namespace plugin\coleappversion\app\api\controller;

use app\common\controller\BaseApiController;
use Carbon\Carbon;
use plugin\coleappversion\app\model\AppVersion;
use support\utils\CacheUtil;

class AppVersionController extends BaseApiController
{
    protected $noNeedLogin = ['*'];

    public function getAppUpdate()
    {
        $system_key = input('system_key', 'android');
        $data=  CacheUtil::remember($system_key,function () use ($system_key) {
            return AppVersion::where([
                ['regular_update', '<', Carbon::now()->toDateTimeString()],
                ['status', '=', 1],
                ['system_key', '=', $system_key],
            ])->order('regular_update','desc')->find();
        },30);
        return $this->success($data);
    }

}
